﻿// Study0904.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第九章 群体数据 数组类 

#include <iostream>
#include <cmath>
#include "..\Study0903\Array.h"
using namespace std;
ostream& operator <<(ostream& out, const Array<int> a)
{
	out << "{\t";
	for (int i = 0; i < a.getSize(); ++i)
	{
		out << a[i] << "\t";
		if (i%10==9)
		{
			out << endl<<"\t";			
		}
		
	}
	out << "}" << endl;
	return out;
}
int main()
{
	Array<int> a(10);
	int count = 0;
	
	for (int i = 2; i <= 100; ++i)
	{
		bool isPrime = true;
		/*if (i==2)
		{
			a[0] = 2;
		}*/
		for (int j = 2; j <= sqrt(i); ++j)
		{
			if (i%j==0)
			{
				isPrime = false;
				break;
			}
			
		}
		if (isPrime)
		{
			
			if (count==a.getSize())
			{
				a.resize(2 * a.getSize());
			}
			a[count] = i;
			++count;
		}
	}
	a.resize(count);
	
	cout << a;
	return 0;
}


